﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Eeml.Core
{
    public class EemlData
    {
        #region Fields

        private IEnumerable<string> _tag;
        private EemlValue _value;
        private Unit _unit;
        private int _id;

        #endregion


        #region Contructors

        public EemlData()
        {
            _id = new Random().Next();
        }

        #endregion


        #region Properties

        public IEnumerable<string> Tag
        {
            get
            {
                if (_tag == null)
                {
                    _tag = new List<string>();
                }
                return _tag;
            }
        }

        public EemlValue Value
        {
            get
            {
                if (_value == null)
                {
                    _value = new EemlValue();
                }
                return _value;
            }
        }

        public Unit Unit
        {
            get
            {
                if (_unit == null)
                {
                    _unit = new Unit();
                }
                return _unit;
            }
        }

        //TODO Properly initialize id
        public int Id
        {
            get
            {
                return _id;
            }
        }

        #endregion


        #region Methods

        public void AddValue(EemlValue value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            _value = value;
        }
        
        #endregion

    }
}
